package cn.brilliantfuture.commentry.entity;

// Generated 2010-9-25 13:15:16 by Hibernate Tools 3.3.0.GA

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.validator.Length;
import org.hibernate.validator.Max;
import org.hibernate.validator.Min;

/**
 * StorageGrid generated by hbm2java
 */
@Entity
@Table(name = "storage_grid", catalog = "cabinet")
public class StorageGrid implements java.io.Serializable, Comparator<StorageGrid> {

	private static final long serialVersionUID = 1L;
	private Integer storageGridId;
	private Lockers lockers;
	private Integer gridNum;
	private int gridType = 1;
	private int businessType = 1;
	private String description;
	private Date insertTime;
	private Integer insertUser;
	private boolean deleted;

	// 配送仓格子温度
	private Float temp;
	// 配送仓格子湿度
	private Float humi;
	private int gridSize;
	
	private int workState = 0;
	
	private boolean opend;
	private boolean hasGoods;
	private boolean tempWorkState;
	private boolean lockWorkState;
	private Date publishTime;
	
	private boolean used = true;

	private Set<StorageGridSensor> storageGridSensor = new HashSet<StorageGridSensor>(
			0);
	private Set<StorageGridPurchaser> storageGridPurchasers = new HashSet<StorageGridPurchaser>(
			0);
	private Set<StorageGridPurchaserNews> storageGridPurchaserNews = new HashSet<StorageGridPurchaserNews>(
			0);
	private Set<ReservePlan> reservePlans = new HashSet<ReservePlan>(0);

	public StorageGrid() {
	}

	public StorageGrid(Integer gridNum, boolean deleted) {
		this.gridNum = gridNum;
		this.deleted = deleted;
	}

	public StorageGrid(Lockers lockers, Integer gridNum, String description,
			Date insertTime, Integer insertUser, boolean deleted,
			Set<StorageGridPurchaser> storageGridPurchasers,
			Set<StorageGridPurchaserNews> storageGridPurchaserNews,
			Set<StorageGridSensor> storageGridSensor, Float temp, Float humi) {
		this.temp = temp;
		this.humi = humi;
		this.storageGridSensor = storageGridSensor;
		this.lockers = lockers;
		this.gridNum = gridNum;
		this.description = description;
		this.insertTime = insertTime;
		this.insertUser = insertUser;
		this.deleted = deleted;
		this.storageGridPurchasers = storageGridPurchasers;
		this.storageGridPurchaserNews = storageGridPurchaserNews;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "storage_grid_id", unique = true, nullable = false)
	public Integer getStorageGridId() {
		return this.storageGridId;
	}

	public void setStorageGridId(Integer storageGridId) {
		this.storageGridId = storageGridId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "lockers_id")
	public Lockers getLockers() {
		return this.lockers;
	}

	public void setLockers(Lockers lockers) {
		this.lockers = lockers;
	}

	@Column(name = "grid_num", nullable = false)
	@Min(value = 1, message = "格子编号,不能是负数,最小从1开始.")
	@Max(value = 99, message = "格子编号最大99.")
	public Integer getGridNum() {
		return this.gridNum;
	}

	public void setGridNum(Integer gridNum) {
		this.gridNum = gridNum;
	}

	@Column(name = "description", length = 200)
	@Length(max = 200)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "insert_time", length = 19)
	public Date getInsertTime() {
		return this.insertTime;
	}

	public void setInsertTime(Date insertTime) {
		this.insertTime = insertTime;
	}

	@Column(name = "insert_user")
	public Integer getInsertUser() {
		return this.insertUser;
	}

	public void setInsertUser(Integer insertUser) {
		this.insertUser = insertUser;
	}

	@Column(name = "deleted", nullable = false)
	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "storageGrid")
	public Set<StorageGridPurchaser> getStorageGridPurchasers() {
		return this.storageGridPurchasers;
	}

	public void setStorageGridPurchasers(
			Set<StorageGridPurchaser> storageGridPurchasers) {
		this.storageGridPurchasers = storageGridPurchasers;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "storageGrid")
	public Set<StorageGridPurchaserNews> getStorageGridPurchaserNews() {
		return this.storageGridPurchaserNews;
	}

	public void setStorageGridPurchaserNews(
			Set<StorageGridPurchaserNews> storageGridPurchaserNews) {
		this.storageGridPurchaserNews = storageGridPurchaserNews;
	}

	public int compare(StorageGrid sg1, StorageGrid sg2) {
		return sg1.getGridNum() - sg2.getGridNum();
	}

	@Column(name = "grid_type", nullable = false)
	public int getGridType() {
		return gridType;
	}

	public void setGridType(int gridType) {
		this.gridType = gridType;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "storageGrid")
	public Set<StorageGridSensor> getStorageGridSensor() {
		return storageGridSensor;
	}

	public void setStorageGridSensor(Set<StorageGridSensor> storageGridSensor) {
		this.storageGridSensor = storageGridSensor;
	}

	@Column(name = "temp", precision = 12, scale = 0)
	public Float getTemp() {
		return temp;
	}

	public void setTemp(Float temp) {
		this.temp = temp;
	}

	@Column(name = "humi", precision = 12, scale = 0)
	public Float getHumi() {
		return humi;
	}

	public void setHumi(Float humi) {
		this.humi = humi;
	}

	@Column(name = "work_state", nullable = false)
	public int getWorkState() {
		return workState;
	}

	public void setWorkState(int workState) {
		this.workState = workState;
	}

	@Column(name = "business_type", nullable = false)
	public int getBusinessType() {
		return businessType;
	}

	public void setBusinessType(int businessType) {
		this.businessType = businessType;
	}

	@Column(name = "has_goods", nullable = false)
	public boolean isHasGoods() {
		return hasGoods;
	}

	public void setHasGoods(boolean hasGoods) {
		this.hasGoods = hasGoods;
	}

	@Column(name = "temp_work_state", nullable = false)
	public boolean isTempWorkState() {
		return tempWorkState;
	}

	public void setTempWorkState(boolean tempWorkState) {
		this.tempWorkState = tempWorkState;
	}

	@Column(name = "lock_work_state", nullable = false)
	public boolean isLockWorkState() {
		return lockWorkState;
	}

	public void setLockWorkState(boolean lockWorkState) {
		this.lockWorkState = lockWorkState;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "publish_time", length = 19)
	public Date getPublishTime() {
		return publishTime;
	}

	public void setPublishTime(Date publishTime) {
		this.publishTime = publishTime;
	}

	@Column(name = "used", nullable = false)
	public boolean isUsed() {
		return used;
	}

	public void setUsed(boolean used) {
		this.used = used;
	}

	@Column(name = "opend", nullable = false)
	public boolean isOpend() {
		return opend;
	}

	public void setOpend(boolean opend) {
		this.opend = opend;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "storageGrid")
	public Set<ReservePlan> getReservePlans() {
		return reservePlans;
	}

	public void setReservePlans(Set<ReservePlan> reservePlans) {
		this.reservePlans = reservePlans;
	}

	@Column(name = "grid_size", nullable = false)
	public int getGridSize() {
		return gridSize;
	}

	public void setGridSize(int gridSize) {
		this.gridSize = gridSize;
	}
}
